package org.dding.mvc.web.tag;

import javax.servlet.ServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;

public class BridgeTag extends SimpleTagSupport {

	private static final long serialVersionUID = 2325405536936686361L;

	private Object value;

	private String var;

	public String getVar() {
		return var;
	}

	public void setVar(String var) {
		this.var = var;
	}

	public Object getValue() {
		return value;
	}

	public void setValue(Object value) {
		this.value = value;
	}

	@Override
	public void doTag() throws JspException {

		ServletRequest request = ((PageContext) getJspContext()).getRequest();
		if (value != null && value instanceof String) {
			Object object = request.getAttribute((String) value);
			request.setAttribute(var, object);
		}

	}
}
